'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	var blank = ""
	var myDate = new Date();
	var year = myDate.getFullYear();
	var month = (myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1);
	var date = myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate();
	var hour = myDate.getHours() < 10 ? '0' + myDate.getHours() : myDate.getHours();
	var min = myDate.getMinutes() < 10 ? '0' + myDate.getMinutes() : myDate.getMinutes();
	var sec = myDate.getSeconds() < 10 ? '0' + myDate.getSeconds() : myDate.getSeconds();
	var myTime = blank.concat(year, "-", month, "-", date, " ", hour, ":", min, ":", sec);
	var day=blank.concat(year, "-", month, "-", date);
	const db = uniCloud.database();
	let obj={
		role_name:event.role_name,
		permission:'admin',
		comment:'备注',
		create_date:day
	}
	const res =  await db.collection('uni-id-roles').add(obj)
	//返回数据给客户端
	return res
};
